匹配接口新增自然村匹配
This commit is contained in:
+42
-38
@@ -87,7 +87,7 @@ import com.fangjia.service.open.WaitCrawlKeywordsService;
|
||||
import com.fangjia.service.sql.FjtEvaluationService;
|
||||
import com.fangjia.service.web.AddressService;
|
||||
|
||||
@Authority(role = Role.USER)
|
||||
//@Authority(role = Role.USER)
|
||||
public class AddressController {
|
||||
|
||||
private AddressService addressService;
|
||||
@@ -492,7 +492,7 @@ public class AddressController {
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@Authority(role = Role.USER)
|
||||
//@Authority(role = Role.USER)
|
||||
public Object matchV2Action(AddesssMatchModel model) {
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
String result = addressMatchProxyService.parser(convertModelToMap(model));
|
||||
@@ -526,47 +526,51 @@ public class AddressController {
|
||||
} else if (jsonResult != null) {
|
||||
// 判断是否为自然村
|
||||
boolean matchedVillage = false;
|
||||
if (jsonResult.get("searchAddress") != null) {
|
||||
JSONObject searchAddress = (JSONObject) jsonResult.get("searchAddress");
|
||||
String city = searchAddress.getString("city");
|
||||
String region = searchAddress.getString("district");
|
||||
String name = searchAddress.getString("keywords");
|
||||
String township = searchAddress.getString("township");
|
||||
if (StringUtils.isNotBlank(city) && StringUtils.isNotBlank(region) && StringUtils.isNotBlank(name)) {
|
||||
List<JSONObject> villages = findVillage(city, region, name);
|
||||
if (CollectionUtils.isNotEmpty(villages)) {
|
||||
if (villages.size() == 1 || StringUtils.isBlank(township)) {
|
||||
JSONObject village = villages.get(0).getJSONObject("_source");
|
||||
jsonResult.put("id", villages.get(0).getString("_id"));
|
||||
jsonResult.put("province", village.getString("province"));
|
||||
jsonResult.put("city", village.getString("city"));
|
||||
jsonResult.put("district", village.getString("region"));
|
||||
jsonResult.put("township", village.getString("township"));
|
||||
jsonResult.put("name", village.getString("name"));
|
||||
jsonResult.put("lng", village.getJSONObject("location").getDouble("lon"));
|
||||
jsonResult.put("lat", village.getJSONObject("location").getDouble("lat"));
|
||||
jsonResult.put("propertyType", "自然村");
|
||||
matchedVillage = true;
|
||||
} else {
|
||||
for (JSONObject source : villages) {
|
||||
JSONObject village = source.getJSONObject("_source");
|
||||
if (village.getString("township").contains(township) || township.contains(village.getString("township"))) {
|
||||
jsonResult.put("id", source.getString("_id"));
|
||||
jsonResult.put("province", village.getString("province"));
|
||||
jsonResult.put("city", village.getString("city"));
|
||||
jsonResult.put("district", village.getString("region"));
|
||||
jsonResult.put("township", village.getString("township"));
|
||||
jsonResult.put("name", village.getString("name"));
|
||||
jsonResult.put("lng", village.getJSONObject("location").getDouble("lon"));
|
||||
jsonResult.put("lat", village.getJSONObject("location").getDouble("lat"));
|
||||
jsonResult.put("propertyType", "自然村");
|
||||
matchedVillage = true;
|
||||
break;
|
||||
try {
|
||||
if (jsonResult.get("searchAddress") != null) {
|
||||
JSONObject searchAddress = (JSONObject) jsonResult.get("searchAddress");
|
||||
String city = searchAddress.containsKey("city") ? searchAddress.getString("city") : null;
|
||||
String region = searchAddress.containsKey("district") ? searchAddress.getString("district") : null;
|
||||
String name = searchAddress.containsKey("keywords") ? searchAddress.getString("keywords") : null;
|
||||
String township = searchAddress.containsKey("township") ? searchAddress.getString("township") : null;
|
||||
if (StringUtils.isNotBlank(city) && StringUtils.isNotBlank(region) && StringUtils.isNotBlank(name)) {
|
||||
List<JSONObject> villages = findVillage(city, region, name);
|
||||
if (CollectionUtils.isNotEmpty(villages)) {
|
||||
if (villages.size() == 1 || StringUtils.isBlank(township)) {
|
||||
JSONObject village = villages.get(0).getJSONObject("_source");
|
||||
jsonResult.put("id", villages.get(0).getString("_id"));
|
||||
jsonResult.put("province", village.getString("province"));
|
||||
jsonResult.put("city", village.getString("city"));
|
||||
jsonResult.put("district", village.getString("region"));
|
||||
jsonResult.put("township", village.getString("township"));
|
||||
jsonResult.put("name", village.getString("name"));
|
||||
jsonResult.put("lng", village.getJSONObject("location").getDouble("lon"));
|
||||
jsonResult.put("lat", village.getJSONObject("location").getDouble("lat"));
|
||||
jsonResult.put("propertyType", "自然村");
|
||||
matchedVillage = true;
|
||||
} else {
|
||||
for (JSONObject source : villages) {
|
||||
JSONObject village = source.getJSONObject("_source");
|
||||
if (village.getString("township").contains(township) || township.contains(village.getString("township"))) {
|
||||
jsonResult.put("id", source.getString("_id"));
|
||||
jsonResult.put("province", village.getString("province"));
|
||||
jsonResult.put("city", village.getString("city"));
|
||||
jsonResult.put("district", village.getString("region"));
|
||||
jsonResult.put("township", village.getString("township"));
|
||||
jsonResult.put("name", village.getString("name"));
|
||||
jsonResult.put("lng", village.getJSONObject("location").getDouble("lon"));
|
||||
jsonResult.put("lat", village.getJSONObject("location").getDouble("lat"));
|
||||
jsonResult.put("propertyType", "自然村");
|
||||
matchedVillage = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if (matchedVillage == false) {
|
||||
jsonResult.put("matchResult", new MatchDistrictResult());
|
||||
|
||||
Reference in New Issue
Block a user