匹配接口新增自然村匹配
This commit is contained in:
+40
-36
@@ -526,47 +526,51 @@ public class AddressController {
|
|||||||
} else if (jsonResult != null) {
|
} else if (jsonResult != null) {
|
||||||
// 判断是否为自然村
|
// 判断是否为自然村
|
||||||
boolean matchedVillage = false;
|
boolean matchedVillage = false;
|
||||||
if (jsonResult.get("searchAddress") != null) {
|
try {
|
||||||
JSONObject searchAddress = (JSONObject) jsonResult.get("searchAddress");
|
if (jsonResult.get("searchAddress") != null) {
|
||||||
String city = searchAddress.getString("city");
|
JSONObject searchAddress = (JSONObject) jsonResult.get("searchAddress");
|
||||||
String region = searchAddress.getString("district");
|
String city = searchAddress.containsKey("city") ? searchAddress.getString("city") : null;
|
||||||
String name = searchAddress.getString("keywords");
|
String region = searchAddress.containsKey("district") ? searchAddress.getString("district") : null;
|
||||||
String township = searchAddress.getString("township");
|
String name = searchAddress.containsKey("keywords") ? searchAddress.getString("keywords") : null;
|
||||||
if (StringUtils.isNotBlank(city) && StringUtils.isNotBlank(region) && StringUtils.isNotBlank(name)) {
|
String township = searchAddress.containsKey("township") ? searchAddress.getString("township") : null;
|
||||||
List<JSONObject> villages = findVillage(city, region, name);
|
if (StringUtils.isNotBlank(city) && StringUtils.isNotBlank(region) && StringUtils.isNotBlank(name)) {
|
||||||
if (CollectionUtils.isNotEmpty(villages)) {
|
List<JSONObject> villages = findVillage(city, region, name);
|
||||||
if (villages.size() == 1 || StringUtils.isBlank(township)) {
|
if (CollectionUtils.isNotEmpty(villages)) {
|
||||||
JSONObject village = villages.get(0).getJSONObject("_source");
|
if (villages.size() == 1 || StringUtils.isBlank(township)) {
|
||||||
jsonResult.put("id", villages.get(0).getString("_id"));
|
JSONObject village = villages.get(0).getJSONObject("_source");
|
||||||
jsonResult.put("province", village.getString("province"));
|
jsonResult.put("id", villages.get(0).getString("_id"));
|
||||||
jsonResult.put("city", village.getString("city"));
|
jsonResult.put("province", village.getString("province"));
|
||||||
jsonResult.put("district", village.getString("region"));
|
jsonResult.put("city", village.getString("city"));
|
||||||
jsonResult.put("township", village.getString("township"));
|
jsonResult.put("district", village.getString("region"));
|
||||||
jsonResult.put("name", village.getString("name"));
|
jsonResult.put("township", village.getString("township"));
|
||||||
jsonResult.put("lng", village.getJSONObject("location").getDouble("lon"));
|
jsonResult.put("name", village.getString("name"));
|
||||||
jsonResult.put("lat", village.getJSONObject("location").getDouble("lat"));
|
jsonResult.put("lng", village.getJSONObject("location").getDouble("lon"));
|
||||||
jsonResult.put("propertyType", "自然村");
|
jsonResult.put("lat", village.getJSONObject("location").getDouble("lat"));
|
||||||
matchedVillage = true;
|
jsonResult.put("propertyType", "自然村");
|
||||||
} else {
|
matchedVillage = true;
|
||||||
for (JSONObject source : villages) {
|
} else {
|
||||||
JSONObject village = source.getJSONObject("_source");
|
for (JSONObject source : villages) {
|
||||||
if (village.getString("township").contains(township) || township.contains(village.getString("township"))) {
|
JSONObject village = source.getJSONObject("_source");
|
||||||
jsonResult.put("id", source.getString("_id"));
|
if (village.getString("township").contains(township) || township.contains(village.getString("township"))) {
|
||||||
jsonResult.put("province", village.getString("province"));
|
jsonResult.put("id", source.getString("_id"));
|
||||||
jsonResult.put("city", village.getString("city"));
|
jsonResult.put("province", village.getString("province"));
|
||||||
jsonResult.put("district", village.getString("region"));
|
jsonResult.put("city", village.getString("city"));
|
||||||
jsonResult.put("township", village.getString("township"));
|
jsonResult.put("district", village.getString("region"));
|
||||||
jsonResult.put("name", village.getString("name"));
|
jsonResult.put("township", village.getString("township"));
|
||||||
jsonResult.put("lng", village.getJSONObject("location").getDouble("lon"));
|
jsonResult.put("name", village.getString("name"));
|
||||||
jsonResult.put("lat", village.getJSONObject("location").getDouble("lat"));
|
jsonResult.put("lng", village.getJSONObject("location").getDouble("lon"));
|
||||||
jsonResult.put("propertyType", "自然村");
|
jsonResult.put("lat", village.getJSONObject("location").getDouble("lat"));
|
||||||
matchedVillage = true;
|
jsonResult.put("propertyType", "自然村");
|
||||||
break;
|
matchedVillage = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch(Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
if (matchedVillage == false) {
|
if (matchedVillage == false) {
|
||||||
jsonResult.put("matchResult", new MatchDistrictResult());
|
jsonResult.put("matchResult", new MatchDistrictResult());
|
||||||
|
|||||||
Reference in New Issue
Block a user