diff --git a/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java b/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java index bcb042e67..29702030e 100644 --- a/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java +++ b/projects/fangjia-core/src/main/java/com/fangjia/core/util/GeoUtils.java @@ -1,265 +1,329 @@ package com.fangjia.core.util; +import org.json.JSONArray; +import org.json.JSONObject; + import java.util.HashMap; import java.util.Map; public class GeoUtils { - - public static final String LAT ="lat"; - - public static final String LNG ="lng"; - - public enum GaussSphere { - Beijing54, Xian80, WGS84, - } - private static double rad(double d) { - return d * Math.PI / 180.0; - } + public static final String LAT = "lat"; - public static double calculateDistance(double lng1, double lat1, double lng2, double lat2) { - return calculateDistance(lng1, lat1, lng2, lat2, GaussSphere.Beijing54); - } + public static final String LNG = "lng"; - public static double calculateDistance(double lng1, double lat1, double lng2, double lat2, GaussSphere gs) { - double radLat1 = rad(lat1); - double radLat2 = rad(lat2); - double a = radLat1 - radLat2; - double b = rad(lng1) - rad(lng2); - double s = 2 * Math.asin(Math.sqrt( - Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); - s = s * (gs == GaussSphere.WGS84 ? 6378137.0 : (gs == GaussSphere.Xian80 ? 6378140.0 : 6378245.0)); - s = Math.round(s * 10000) / 10000; - return s; - } + public enum GaussSphere { + Beijing54, Xian80, WGS84, + } - /** - * @param raidus - * 单位米 - * - * @return minLat,maxLat, minLng,maxLng - */ - public static double[] getAround(double lat, double lng, double radius) { - Double latitude = lat; - Double longitude = lng; - Double degree = (24901 * 1609) / 360.0; - double raidusMile = radius; + private static double rad(double d) { + return d * Math.PI / 180.0; + } - Double dpmLat = 1 / degree; - Double radiusLat = dpmLat * raidusMile; - Double minLat = latitude - radiusLat; - Double maxLat = latitude + radiusLat; + public static double calculateDistance(double lng1, double lat1, double lng2, double lat2) { + return calculateDistance(lng1, lat1, lng2, lat2, GaussSphere.Beijing54); + } - Double mpdLng = degree * Math.cos(latitude * (Math.PI / 180)); - Double dpmLng = 1 / mpdLng; - Double radiusLng = dpmLng * raidusMile; - Double minLng = longitude - radiusLng; - Double maxLng = longitude + radiusLng; - return new double[] { minLat, maxLat, minLng, maxLng }; - } + public static double calculateDistance(double lng1, double lat1, double lng2, double lat2, GaussSphere gs) { + double radLat1 = rad(lat1); + double radLat2 = rad(lat2); + double a = radLat1 - radLat2; + double b = rad(lng1) - rad(lng2); + double s = 2 * Math.asin(Math.sqrt( + Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); + s = s * (gs == GaussSphere.WGS84 ? 6378137.0 : (gs == GaussSphere.Xian80 ? 6378140.0 : 6378245.0)); + s = Math.round(s * 10000) / 10000; + return s; + } - /** - * 根据给定的经纬度、距离、角度,计算对应的经纬度 - * - * @param Lat - * 原始纬度 - * @param Lon - * 原始精度 - * @param distance - * 距离(米) - * @param angle - * , 90: right, 180: down - * @return - */ - public static double[] getLatLon(double Lon, double Lat, int distance, double angle) { - double dx = distance * Math.sin(angle * Math.PI / 180); - double dy = distance * Math.cos(angle * Math.PI / 180); + /** + * @param raidus 单位米 + * @return minLat, maxLat, minLng,maxLng + */ + public static double[] getAround(double lat, double lng, double radius) { + Double latitude = lat; + Double longitude = lng; + Double degree = (24901 * 1609) / 360.0; + double raidusMile = radius; - double lon1 = (dx / edd(Lat) + eadLon(Lon)) * 180 / Math.PI; - double lat1 = (dy / ecc(Lat) + radLat(Lat)) * 180 / Math.PI; + Double dpmLat = 1 / degree; + Double radiusLat = dpmLat * raidusMile; + Double minLat = latitude - radiusLat; + Double maxLat = latitude + radiusLat; - return new double[] { lon1, lat1 }; - } + Double mpdLng = degree * Math.cos(latitude * (Math.PI / 180)); + Double dpmLng = 1 / mpdLng; + Double radiusLng = dpmLng * raidusMile; + Double minLng = longitude - radiusLng; + Double maxLng = longitude + radiusLng; + return new double[]{minLat, maxLat, minLng, maxLng}; + } - /** - * 纬度的弧度 - */ - public static double radLat(double Lat) { - return Lat * Math.PI / 180; - } + /** + * 根据给定的经纬度、距离、角度,计算对应的经纬度 + * + * @param Lat 原始纬度 + * @param Lon 原始精度 + * @param distance 距离(米) + * @param angle , 90: right, 180: down + * @return + */ + public static double[] getLatLon(double Lon, double Lat, int distance, double angle) { + double dx = distance * Math.sin(angle * Math.PI / 180); + double dy = distance * Math.cos(angle * Math.PI / 180); - /** - * 经度的弧度 - */ - public static double eadLon(double Lon) { - return Lon * Math.PI / 180; - } + double lon1 = (dx / edd(Lat) + eadLon(Lon)) * 180 / Math.PI; + double lat1 = (dy / ecc(Lat) + radLat(Lat)) * 180 / Math.PI; - public static double edd(double Lat) { - double ec = ecc(Lat); - double radLat = radLat(Lat); - return ec * Math.cos(radLat); - } + return new double[]{lon1, lat1}; + } - final static int EARTH_RADIUS = 6378137;// 赤道半径 earth radius - final static int POLAR_RADIUS = 6356725;// 极半径 polar radius + /** + * 纬度的弧度 + */ + public static double radLat(double Lat) { + return Lat * Math.PI / 180; + } - public static double ecc(double Lat) { - return POLAR_RADIUS + (EARTH_RADIUS - POLAR_RADIUS) * (90 - Lat) / 90; - } + /** + * 经度的弧度 + */ + public static double eadLon(double Lon) { + return Lon * Math.PI / 180; + } - // public static void main(String[] args) { + public static double edd(double Lat) { + double ec = ecc(Lat); + double radLat = radLat(Lat); + return ec * Math.cos(radLat); + } + + final static int EARTH_RADIUS = 6378137;// 赤道半径 earth radius + final static int POLAR_RADIUS = 6356725;// 极半径 polar radius + + public static double ecc(double Lat) { + return POLAR_RADIUS + (EARTH_RADIUS - POLAR_RADIUS) * (90 - Lat) / 90; + } + + // public static void main(String[] args) { // System.out.println(calculateDistance(121.35913,31.222278, // 121.36441151585116,31.21939479450005)); - + // Map s = bd09ToGps84(121.37032165267994,31.226171036022064); // System.out.println(s.get(LAT)); // System.out.println(s.get(LNG)); // } - public static double pi = 3.1415926535897932384626; - public static double a = 6378245.0; - public static double ee = 0.00669342162296594323; - - /** - * 百度转 wgs84 - * @param bd_lat - * @param bd_lng - * @return - */ - public static Map bd09ToGps84(double bd_lat, double bd_lng) { - Map gps = bd09ToGcj02(bd_lat,bd_lng); - return gcjToGps84(gps.get(LAT),gps.get(LNG)); - } - /** - * wgs84 转百度 - * @param bd_lat - * @param bd_lng - * @return - */ - public static Map Gps84Tobd09(double lat, double lng) { - Map gps = gps84ToGcj02(lat,lng); - return gcj02ToBd09(gps.get(LAT),gps.get(LNG)); - } + public static double pi = 3.1415926535897932384626; + public static double a = 6378245.0; + public static double ee = 0.00669342162296594323; - /** - * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 将 BD-09 坐标转换成GCJ-02 坐标 - */ - public static Map bd09ToGcj02(double bd_lat, double bd_lng) { - double x = bd_lng - 0.0065, y = bd_lat - 0.006; - double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * pi); - double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * pi); - double gg_lng = z * Math.cos(theta); - double gg_lat = z * Math.sin(theta); - Map gps = new HashMap(); - gps.put(LAT, gg_lat); - gps.put(LNG, gg_lng); - return gps; - } + /** + * 百度转 wgs84 + * + * @param bd_lat + * @param bd_lng + * @return + */ + public static Map bd09ToGps84(double bd_lat, double bd_lng) { + Map gps = bd09ToGcj02(bd_lat, bd_lng); + return gcjToGps84(gps.get(LAT), gps.get(LNG)); + } - /** - * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 将 GCJ-02 坐标转换成 BD-09 坐标 - */ - public static Map gcj02ToBd09(double gg_lat, double gg_lng) { - double x = gg_lng, y = gg_lat; - double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi); - double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi); - double bd_lng = z * Math.cos(theta) + 0.0065; - double bd_lat = z * Math.sin(theta) + 0.006; - Map gps = new HashMap(); - gps.put(LAT, bd_lat); - gps.put(LNG, bd_lng); - return gps; - } + /** + * wgs84 转百度 + * + * @param bd_lat + * @param bd_lng + * @return + */ + public static Map Gps84Tobd09(double lat, double lng) { + Map gps = gps84ToGcj02(lat, lng); + return gcj02ToBd09(gps.get(LAT), gps.get(LNG)); + } - /** - * 地球坐标系 (WGS84) 与火星坐标系 (GCJ-02) 的转换算法 将 WGS84 坐标转换成 GCJ-02 坐标 - */ - public static Map gps84ToGcj02(double lat, double lng) { - if (outOfChina(lat, lng)) { - Map gps = new HashMap(); - gps.put(LAT, lat); - gps.put(LNG, lng); - return gps; - } - double dLat = transformLat(lng - 105.0, lat - 35.0); - double dlng = transformlng(lng - 105.0, lat - 35.0); - double radLat = lat / 180.0 * pi; - double magic = Math.sin(radLat); - magic = 1 - ee * magic * magic; - double sqrtMagic = Math.sqrt(magic); - dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); - dlng = (dlng * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi); - double mgLat = lat + dLat; - double mglng = lng + dlng; - Map gps = new HashMap(); - gps.put(LAT, mgLat); - gps.put(LNG, mglng); - return gps; - } + /** + * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 将 BD-09 坐标转换成GCJ-02 坐标 + */ + public static Map bd09ToGcj02(double bd_lat, double bd_lng) { + double x = bd_lng - 0.0065, y = bd_lat - 0.006; + double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * pi); + double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * pi); + double gg_lng = z * Math.cos(theta); + double gg_lat = z * Math.sin(theta); + Map gps = new HashMap(); + gps.put(LAT, gg_lat); + gps.put(LNG, gg_lng); + return gps; + } - /** - * 地球坐标系 (WGS84) 与火星坐标系 (GCJ-02) 的转换算法 将 GCJ-02 坐标转换成 WGS84 坐标 - */ - public static Map gcjToGps84(double lat, double lng) { - Map gps = transform(lat, lng); - double lngtitude = lng * 2 - gps.get(LNG); - double latitude = lat * 2 - gps.get(LAT); - Map gps2 = new HashMap(); - gps2.put(LAT, latitude); - gps2.put(LNG, lngtitude); - return gps2; - } + /** + * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 将 GCJ-02 坐标转换成 BD-09 坐标 + */ + public static Map gcj02ToBd09(double gg_lat, double gg_lng) { + double x = gg_lng, y = gg_lat; + double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi); + double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi); + double bd_lng = z * Math.cos(theta) + 0.0065; + double bd_lat = z * Math.sin(theta) + 0.006; + Map gps = new HashMap(); + gps.put(LAT, bd_lat); + gps.put(LNG, bd_lng); + return gps; + } - public static boolean outOfChina(double lat, double lng) { - if (lng < 72.004 || lng > 137.8347) - return true; - if (lat < 0.8293 || lat > 55.8271) - return true; - return false; - } + /** + * 地球坐标系 (WGS84) 与火星坐标系 (GCJ-02) 的转换算法 将 WGS84 坐标转换成 GCJ-02 坐标 + */ + public static Map gps84ToGcj02(double lat, double lng) { + if (outOfChina(lat, lng)) { + Map gps = new HashMap(); + gps.put(LAT, lat); + gps.put(LNG, lng); + return gps; + } + double dLat = transformLat(lng - 105.0, lat - 35.0); + double dlng = transformlng(lng - 105.0, lat - 35.0); + double radLat = lat / 180.0 * pi; + double magic = Math.sin(radLat); + magic = 1 - ee * magic * magic; + double sqrtMagic = Math.sqrt(magic); + dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); + dlng = (dlng * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi); + double mgLat = lat + dLat; + double mglng = lng + dlng; + Map gps = new HashMap(); + gps.put(LAT, mgLat); + gps.put(LNG, mglng); + return gps; + } - private static Map transform(double lat, double lng) { - if (outOfChina(lat, lng)) { - Map gps = new HashMap(); - gps.put(LAT, lat); - gps.put(LNG, lng); - return gps; - } - double dLat = transformLat(lng - 105.0, lat - 35.0); - double dlng = transformlng(lng - 105.0, lat - 35.0); - double radLat = lat / 180.0 * pi; - double magic = Math.sin(radLat); - magic = 1 - ee * magic * magic; - double sqrtMagic = Math.sqrt(magic); - dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); - dlng = (dlng * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi); - double mgLat = lat + dLat; - double mglng = lng + dlng; - Map gps = new HashMap(); - gps.put(LAT, mgLat); - gps.put(LNG, mglng); - return gps; - } + /** + * 地球坐标系 (WGS84) 与火星坐标系 (GCJ-02) 的转换算法 将 GCJ-02 坐标转换成 WGS84 坐标 + */ + public static Map gcjToGps84(double lat, double lng) { + Map gps = transform(lat, lng); + double lngtitude = lng * 2 - gps.get(LNG); + double latitude = lat * 2 - gps.get(LAT); + Map gps2 = new HashMap(); + gps2.put(LAT, latitude); + gps2.put(LNG, lngtitude); + return gps2; + } - private static double transformLat(double x, double y) { - double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x)); - ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0; - ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0; - ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0; - return ret; - } + public static boolean outOfChina(double lat, double lng) { + if (lng < 72.004 || lng > 137.8347) + return true; + if (lat < 0.8293 || lat > 55.8271) + return true; + return false; + } - private static double transformlng(double x, double y) { - double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x)); - ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0; - ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0; - ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 * pi)) * 2.0 / 3.0; - return ret; - } + private static Map transform(double lat, double lng) { + if (outOfChina(lat, lng)) { + Map gps = new HashMap(); + gps.put(LAT, lat); + gps.put(LNG, lng); + return gps; + } + double dLat = transformLat(lng - 105.0, lat - 35.0); + double dlng = transformlng(lng - 105.0, lat - 35.0); + double radLat = lat / 180.0 * pi; + double magic = Math.sin(radLat); + magic = 1 - ee * magic * magic; + double sqrtMagic = Math.sqrt(magic); + dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); + dlng = (dlng * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi); + double mgLat = lat + dLat; + double mglng = lng + dlng; + Map gps = new HashMap(); + gps.put(LAT, mgLat); + gps.put(LNG, mglng); + return gps; + } - public static void main(String[] args){ - Map location = gps84ToGcj02(31.218024629574998,121.36562884455); - System.out.println(location.toString()); - } + private static double transformLat(double x, double y) { + double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x)); + ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0; + ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0; + ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0; + return ret; + } + + private static double transformlng(double x, double y) { + double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x)); + ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0; + ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0; + ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 * pi)) * 2.0 / 3.0; + return ret; + } + + public static Map parserByGaode(String city, String address) { + Map params = new HashMap(); + params.put("city", city); + params.put("address", address); + String content; + + try { + params.put("key", getGaodeKey("v3/geocode/geo")); + content = new HttpRequest().get("https://restapi.amap.com/v3/geocode/geo", params, "utf-8"); + } catch (Exception e) { + params.put("key", getGaodeKey("v3/geocode/geo")); + try { + content = new HttpRequest().get("https://restapi.amap.com/v3/geocode/geo", params, "utf-8"); + } catch (HttpRequestException ex) { + throw new RuntimeException(ex); + } + } + + JSONObject json = new JSONObject(content); + if (json != null && "OK".equals(json.optString("info"))) { + JSONArray ret = json.getJSONArray("geocodes"); + if (ret.length() > 0) { + JSONObject firstResult = ret.getJSONObject(0); + String str = firstResult.getString("location"); + String cityA = firstResult.getString("city"); + String district = firstResult.getString("district"); + JSONArray township = firstResult.getJSONArray("township"); + String level = firstResult.getString("level"); + String[] arrs = str.split(","); + Map result = new HashMap(); + result.put("lng", arrs[0]); + result.put("lat", arrs[1]); + result.put("level", level); + result.put("city", cityA); + result.put("district", district); + if (township.length() > 0) { + result.put("town", township.toString()); + } + return result; + } + } else if (json != null && "10044".equals(json.optString("infocode"))) { + System.exit(1); + } else if (json != null && "10004".equals(json.optString("infocode"))) { + // 开发者的单位时间内(1分钟)访问量超限,被系统自动封停,下一分钟自动解封。 + try { + Thread.sleep(60000); + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); + } + } else if (json != null && "10017".equals(json.optString("infocode"))) { + // 所请求的资源不可用 + System.exit(1); + } + + return null; // 如果没有返回值,可以根据需要处理 + } + + private static String getGaodeKey(String endpoint) { + // 实现获取高德 API key 的逻辑 + return "8796b9dfb3889b57c38e2fff1b7e51bd"; + } + + public static void main(String[] args) { +// Map location = gps84ToGcj02(31.218024629574998,121.36562884455); +// System.out.println(location.toString()); + Map result = parserByGaode("上海", "新泾三村"); + System.out.println(result.toString()); + } } diff --git a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java index bca8b4100..1e5116556 100644 --- a/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java +++ b/projects/fangjia-open/src/main/java/com/fangjia/open/controllers/PropertyController.java @@ -180,6 +180,8 @@ public class PropertyController { private static final int DEFAULT_PAGE_SIZE = 20; private static final int DEFAULT_HOUSE_COUNT = 5; private static final String[] PROPERTY_SEARCH_API_FIELDS = {"address", "city", "region", "name", "lat2", "lng2", "lat", "lng", "block", "estateType2", "addrAlias", "alias"}; + + private static final List GAODE_LEVEL = Arrays.asList("兴趣点", "门牌号", "单元号", "楼层", "房间", "门址", "住宅区"); static final int BAI_DU_GEO = 1;// 百度系坐标 static final int GAO_DE_GEO = 2;// 高德系坐标 @@ -1622,7 +1624,32 @@ public class PropertyController { } if (district == null) { - mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!")); + //加上高德获取经纬度 和 根据经纬度估值 + Map map = GeoUtils.parserByGaode(model.getCity(), model.getAddress()); + if (map.containsKey("level") && GAODE_LEVEL.contains(map.get("level")) + && map.containsKey("lng") && map.containsKey("lat")) { + String location = map.get("lng") + "," + map.get("lat"); + HttpRequest httpRequest = new HttpRequest(); + JSONObject json = null; + Map param = new HashMap(); + param.put("location", location); + param.put("area", String.valueOf(model.getSize())); + try { + json = httpRequest.getJsonContent("http://192.168.0.100:30020/avmWeb/avmAnn", param, "UTF-8"); + if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) { + HashMap resultMap = new HashMap(); + resultMap.put("avgPrice",json.getString("unitPrice")); + resultMap.put("totalPrice",json.getString("totalPrice")); + mav.setModel(BasicModel.buildOKModel().setResult(resultMap)); + } else { + mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!")); + } + } catch (HttpRequestException e) { + throw new RuntimeException(e); + } + } else { + mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!")); + } return mav; } model.setDistrict(district.getRegion()); @@ -2508,7 +2535,7 @@ public class PropertyController { } Date startDate = DateUtil.add(new Date(), Calendar.MONTH, -model.getPeriodCount()); - List sqmetreRents = sqmetreRentService.findSqmetreRents(RegionData.formatCity(model.getCity()), RegionData.formatRegion(model.getCity(),model.getDistrict()), model.getName(), model.getCat(), startDate, null); + List sqmetreRents = sqmetreRentService.findSqmetreRents(RegionData.formatCity(model.getCity()), RegionData.formatRegion(model.getCity(), model.getDistrict()), model.getName(), model.getCat(), startDate, null); List> result = new ArrayList>(model.getPeriodCount()); for (SqmetreRent sqmetreRent : sqmetreRents) {