地址为字符串null报错的异常解决
This commit is contained in:
+90
-86
@@ -113,9 +113,9 @@ public class AddressController {
|
|||||||
private static final String ES_PASSWORD = "5e8edd851d2fdfbd7415232c67367cc3";
|
private static final String ES_PASSWORD = "5e8edd851d2fdfbd7415232c67367cc3";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated see parse2Action
|
|
||||||
* @param model
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
|
* @deprecated see parse2Action
|
||||||
*/
|
*/
|
||||||
@Authority(role = Role.USER)
|
@Authority(role = Role.USER)
|
||||||
public Object parseAction(AddressModel model) {
|
public Object parseAction(AddressModel model) {
|
||||||
@@ -163,7 +163,7 @@ public class AddressController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Authority(role = Role.USER)
|
@Authority(role = Role.USER)
|
||||||
public Object analyzeAction(AddressModel model){
|
public Object analyzeAction(AddressModel model) {
|
||||||
RestfulModelAndView mav = new RestfulModelAndView();
|
RestfulModelAndView mav = new RestfulModelAndView();
|
||||||
if (StringUtils.isBlank(model.getCity())) {
|
if (StringUtils.isBlank(model.getCity())) {
|
||||||
mav.setModel(BasicModel.buildBadRequestModel("城市不能为空"));
|
mav.setModel(BasicModel.buildBadRequestModel("城市不能为空"));
|
||||||
@@ -481,9 +481,10 @@ public class AddressController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 地址匹配第二个版本,基于第一个版本的逻辑,对匹配出的结果进行正确性的判断
|
* 地址匹配第二个版本,基于第一个版本的逻辑,对匹配出的结果进行正确性的判断
|
||||||
* @author yinjihuan
|
*
|
||||||
* @param model
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
|
* @author yinjihuan
|
||||||
*/
|
*/
|
||||||
@Authority(role = Role.USER)
|
@Authority(role = Role.USER)
|
||||||
public Object matchV2Action(AddesssMatchModel model) {
|
public Object matchV2Action(AddesssMatchModel model) {
|
||||||
@@ -569,7 +570,7 @@ public class AddressController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
if (matchedVillage == false) {
|
if (matchedVillage == false) {
|
||||||
@@ -970,7 +971,7 @@ public class AddressController {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSONObject addTerm(String name, String value){
|
private JSONObject addTerm(String name, String value) {
|
||||||
JSONObject term = new JSONObject();
|
JSONObject term = new JSONObject();
|
||||||
JSONObject match = new JSONObject();
|
JSONObject match = new JSONObject();
|
||||||
match.put(name, value);
|
match.put(name, value);
|
||||||
@@ -978,7 +979,7 @@ public class AddressController {
|
|||||||
return term;
|
return term;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSONObject addMatchPhrase(String name, String value){
|
private JSONObject addMatchPhrase(String name, String value) {
|
||||||
JSONObject term = new JSONObject();
|
JSONObject term = new JSONObject();
|
||||||
JSONObject match = new JSONObject();
|
JSONObject match = new JSONObject();
|
||||||
match.put(name, value);
|
match.put(name, value);
|
||||||
@@ -1007,20 +1008,20 @@ public class AddressController {
|
|||||||
query.put("bool", bool);
|
query.put("bool", bool);
|
||||||
reqBody.put("query", query);
|
reqBody.put("query", query);
|
||||||
Base64 token = new Base64();
|
Base64 token = new Base64();
|
||||||
String authenticationEncoding = token.encodeAsString((""+ES_USER+":"+ES_PASSWORD+"").getBytes());
|
String authenticationEncoding = token.encodeAsString(("" + ES_USER + ":" + ES_PASSWORD + "").getBytes());
|
||||||
HttpRequest request = new HttpRequest();
|
HttpRequest request = new HttpRequest();
|
||||||
Map<String, String> headers = new HashMap<String, String>();
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
headers.put("Content-Type", "application/json");
|
headers.put("Content-Type", "application/json");
|
||||||
headers.put("Authorization", "Basic "+authenticationEncoding+"");
|
headers.put("Authorization", "Basic " + authenticationEncoding + "");
|
||||||
try {
|
try {
|
||||||
String response = request.postWithBody("http://192.168.0.45:9200/village/_search", reqBody, headers, "UTF-8");
|
String response = request.postWithBody("http://192.168.0.45:9200/village/_search", reqBody, headers, "UTF-8");
|
||||||
JSONObject json = JSONObject.fromObject(response);
|
JSONObject json = JSONObject.fromObject(response);
|
||||||
if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")){
|
if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
JSONArray hits = json.getJSONObject("hits").getJSONArray("hits");
|
JSONArray hits = json.getJSONObject("hits").getJSONArray("hits");
|
||||||
List<JSONObject> results = new ArrayList<JSONObject>();
|
List<JSONObject> results = new ArrayList<JSONObject>();
|
||||||
for(int i=0 ;i < hits.size(); i++){
|
for (int i = 0; i < hits.size(); i++) {
|
||||||
JSONObject jsonObject = hits.getJSONObject(i);
|
JSONObject jsonObject = hits.getJSONObject(i);
|
||||||
results.add(jsonObject);
|
results.add(jsonObject);
|
||||||
}
|
}
|
||||||
@@ -1683,8 +1684,7 @@ public class AddressController {
|
|||||||
/**
|
/**
|
||||||
* 地址评级
|
* 地址评级
|
||||||
*
|
*
|
||||||
* @param model
|
* @param model (city+address)+addressId
|
||||||
* (city+address)+addressId
|
|
||||||
* @return { "code": 200, "msg": "ok", "result": { "data": { "address": "匹配地址",
|
* @return { "code": 200, "msg": "ok", "result": { "data": { "address": "匹配地址",
|
||||||
* "city": "城市", "keyWords": "用户输入", "keyWordsUse": "用户输入格式化", "lat":
|
* "city": "城市", "keyWords": "用户输入", "keyWordsUse": "用户输入格式化", "lat":
|
||||||
* 经纬度, "lng": 经纬度, "name": "匹配POIName", "score": 评分 }, "type": "可能存在" }
|
* 经纬度, "lng": 经纬度, "name": "匹配POIName", "score": 评分 }, "type": "可能存在" }
|
||||||
@@ -1719,8 +1719,7 @@ public class AddressController {
|
|||||||
/**
|
/**
|
||||||
* 地址反欺诈 (地址验真+周边查询)
|
* 地址反欺诈 (地址验真+周边查询)
|
||||||
*
|
*
|
||||||
* @param model
|
* @param model (city+address)+addressId
|
||||||
* (city+address)+addressId
|
|
||||||
* @return { "code": 200, "msg": "ok", "result": { "data": { "address": "匹配地址",
|
* @return { "code": 200, "msg": "ok", "result": { "data": { "address": "匹配地址",
|
||||||
* "city": "城市", "keyWords": "用户输入", "keyWordsUse": "用户输入格式化", "lat":
|
* "city": "城市", "keyWords": "用户输入", "keyWordsUse": "用户输入格式化", "lat":
|
||||||
* 纬度, "lng": 经度, "name": "匹配POIName", "poiList":[ { "name" :
|
* 纬度, "lng": 经度, "name": "匹配POIName", "poiList":[ { "name" :
|
||||||
@@ -1757,8 +1756,7 @@ public class AddressController {
|
|||||||
/**
|
/**
|
||||||
* 地址反欺诈 (地址验真+周边查询)
|
* 地址反欺诈 (地址验真+周边查询)
|
||||||
*
|
*
|
||||||
* @param model
|
* @param model (city+address)+addressId
|
||||||
* (city+address)+addressId
|
|
||||||
* @return { "code": 200, "msg": "ok", "result": { "data": { "address":
|
* @return { "code": 200, "msg": "ok", "result": { "data": { "address":
|
||||||
* "德州路220弄小区", "addressId": "d525e60aab2e84909d2fd998b0af5e8e", "city":
|
* "德州路220弄小区", "addressId": "d525e60aab2e84909d2fd998b0af5e8e", "city":
|
||||||
* "上海市", "keyWords": "德州路220弄", "keyWordsUse": "德州路220弄", "lat":
|
* "上海市", "keyWords": "德州路220弄", "keyWordsUse": "德州路220弄", "lat":
|
||||||
@@ -1809,7 +1807,7 @@ public class AddressController {
|
|||||||
int code = json.getInt("code");
|
int code = json.getInt("code");
|
||||||
String msg = json.getString("msg");
|
String msg = json.getString("msg");
|
||||||
BasicModel basicModel = new BasicModel(code, msg);
|
BasicModel basicModel = new BasicModel(code, msg);
|
||||||
if(json.containsKey("result")){
|
if (json.containsKey("result")) {
|
||||||
basicModel.setResult(json.get("result"));
|
basicModel.setResult(json.get("result"));
|
||||||
}
|
}
|
||||||
mav.setModel(basicModel);
|
mav.setModel(basicModel);
|
||||||
@@ -1839,12 +1837,12 @@ public class AddressController {
|
|||||||
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : CONFIG.getDefaultCity());
|
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : CONFIG.getDefaultCity());
|
||||||
params.put("address", model.getAddress());
|
params.put("address", model.getAddress());
|
||||||
params.put("showCode", model.getShowCode());
|
params.put("showCode", model.getShowCode());
|
||||||
try{
|
|
||||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structure", params, "UTF-8");
|
|
||||||
} catch(Exception e){
|
|
||||||
try {
|
try {
|
||||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structure", params, "UTF-8");
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structure", params, "UTF-8");
|
||||||
} catch(Exception ex){
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structure", params, "UTF-8");
|
||||||
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1853,7 +1851,7 @@ public class AddressController {
|
|||||||
int code = json.getInt("status");
|
int code = json.getInt("status");
|
||||||
String msg = json.getString("msg");
|
String msg = json.getString("msg");
|
||||||
BasicModel basicModel = new BasicModel(code, msg);
|
BasicModel basicModel = new BasicModel(code, msg);
|
||||||
if(json.containsKey("result")){
|
if (json.containsKey("result")) {
|
||||||
basicModel.setResult(json.get("result"));
|
basicModel.setResult(json.get("result"));
|
||||||
}
|
}
|
||||||
mav.setModel(basicModel);
|
mav.setModel(basicModel);
|
||||||
@@ -1877,12 +1875,12 @@ public class AddressController {
|
|||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : CONFIG.getDefaultCity());
|
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : CONFIG.getDefaultCity());
|
||||||
params.put("address", model.getAddress());
|
params.put("address", model.getAddress());
|
||||||
try{
|
|
||||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/cmbTest", params, "UTF-8");
|
|
||||||
} catch(Exception e){
|
|
||||||
try {
|
try {
|
||||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/cmbTest", params, "UTF-8");
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/cmbTest", params, "UTF-8");
|
||||||
} catch(Exception ex){
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/cmbTest", params, "UTF-8");
|
||||||
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1891,7 +1889,7 @@ public class AddressController {
|
|||||||
int code = json.getInt("status");
|
int code = json.getInt("status");
|
||||||
String msg = json.getString("msg");
|
String msg = json.getString("msg");
|
||||||
BasicModel basicModel = new BasicModel(code, msg);
|
BasicModel basicModel = new BasicModel(code, msg);
|
||||||
if(json.containsKey("result")){
|
if (json.containsKey("result")) {
|
||||||
basicModel.setResult(json.get("result"));
|
basicModel.setResult(json.get("result"));
|
||||||
}
|
}
|
||||||
mav.setModel(basicModel);
|
mav.setModel(basicModel);
|
||||||
@@ -1922,12 +1920,12 @@ public class AddressController {
|
|||||||
params.put("address", model.getAddress());
|
params.put("address", model.getAddress());
|
||||||
// 地址验证无效也输出标准化结果
|
// 地址验证无效也输出标准化结果
|
||||||
params.put("flag", "true");
|
params.put("flag", "true");
|
||||||
try{
|
|
||||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure", params, "UTF-8");
|
|
||||||
} catch(Exception e){
|
|
||||||
try {
|
try {
|
||||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure", params, "UTF-8");
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure", params, "UTF-8");
|
||||||
} catch(Exception ex){
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure", params, "UTF-8");
|
||||||
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1936,7 +1934,7 @@ public class AddressController {
|
|||||||
int code = json.getInt("status");
|
int code = json.getInt("status");
|
||||||
String msg = json.getString("msg");
|
String msg = json.getString("msg");
|
||||||
BasicModel basicModel = new BasicModel(code, msg);
|
BasicModel basicModel = new BasicModel(code, msg);
|
||||||
if(json.containsKey("result")){
|
if (json.containsKey("result")) {
|
||||||
basicModel.setResult(json.get("result"));
|
basicModel.setResult(json.get("result"));
|
||||||
}
|
}
|
||||||
mav.setModel(basicModel);
|
mav.setModel(basicModel);
|
||||||
@@ -1967,12 +1965,12 @@ public class AddressController {
|
|||||||
params.put("address", model.getAddress());
|
params.put("address", model.getAddress());
|
||||||
// 地址验证无效也输出标准化结果
|
// 地址验证无效也输出标准化结果
|
||||||
params.put("flag", "true");
|
params.put("flag", "true");
|
||||||
try{
|
|
||||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure/v2", params, "UTF-8");
|
|
||||||
} catch(Exception e){
|
|
||||||
try {
|
try {
|
||||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure/v2", params, "UTF-8");
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure/v2", params, "UTF-8");
|
||||||
} catch(Exception ex){
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/fiveDivisionStructure/v2", params, "UTF-8");
|
||||||
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1981,7 +1979,7 @@ public class AddressController {
|
|||||||
int code = json.getInt("status");
|
int code = json.getInt("status");
|
||||||
String msg = json.getString("msg");
|
String msg = json.getString("msg");
|
||||||
BasicModel basicModel = new BasicModel(code, msg);
|
BasicModel basicModel = new BasicModel(code, msg);
|
||||||
if(json.containsKey("result")){
|
if (json.containsKey("result")) {
|
||||||
basicModel.setResult(json.get("result"));
|
basicModel.setResult(json.get("result"));
|
||||||
}
|
}
|
||||||
mav.setModel(basicModel);
|
mav.setModel(basicModel);
|
||||||
@@ -2012,12 +2010,12 @@ public class AddressController {
|
|||||||
params.put("address", model.getAddress());
|
params.put("address", model.getAddress());
|
||||||
// 地址验证无效也输出标准化结果
|
// 地址验证无效也输出标准化结果
|
||||||
params.put("flag", "true");
|
params.put("flag", "true");
|
||||||
try{
|
|
||||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/divisionStructure", params, "UTF-8");
|
|
||||||
} catch(Exception e){
|
|
||||||
try {
|
try {
|
||||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/divisionStructure", params, "UTF-8");
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/divisionStructure", params, "UTF-8");
|
||||||
} catch(Exception ex){
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/divisionStructure", params, "UTF-8");
|
||||||
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2026,7 +2024,7 @@ public class AddressController {
|
|||||||
int code = json.getInt("status");
|
int code = json.getInt("status");
|
||||||
String msg = json.getString("msg");
|
String msg = json.getString("msg");
|
||||||
BasicModel basicModel = new BasicModel(code, msg);
|
BasicModel basicModel = new BasicModel(code, msg);
|
||||||
if(json.containsKey("result")){
|
if (json.containsKey("result")) {
|
||||||
basicModel.setResult(json.get("result"));
|
basicModel.setResult(json.get("result"));
|
||||||
}
|
}
|
||||||
mav.setModel(basicModel);
|
mav.setModel(basicModel);
|
||||||
@@ -2038,6 +2036,7 @@ public class AddressController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 地址标准化专用测试接口
|
* 地址标准化专用测试接口
|
||||||
|
*
|
||||||
* @param model
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -2056,12 +2055,12 @@ public class AddressController {
|
|||||||
params.put("address", model.getAddress());
|
params.put("address", model.getAddress());
|
||||||
// 地址验证无效也输出标准化结果
|
// 地址验证无效也输出标准化结果
|
||||||
params.put("flag", "true");
|
params.put("flag", "true");
|
||||||
try{
|
|
||||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structureAndComplete", params, "UTF-8");
|
|
||||||
} catch(Exception e){
|
|
||||||
try {
|
try {
|
||||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structureAndComplete", params, "UTF-8");
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structureAndComplete", params, "UTF-8");
|
||||||
} catch(Exception ex){
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structureAndComplete", params, "UTF-8");
|
||||||
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2070,7 +2069,7 @@ public class AddressController {
|
|||||||
int code = json.getInt("status");
|
int code = json.getInt("status");
|
||||||
String msg = json.getString("msg");
|
String msg = json.getString("msg");
|
||||||
BasicModel basicModel = new BasicModel(code, msg);
|
BasicModel basicModel = new BasicModel(code, msg);
|
||||||
if(json.containsKey("result")){
|
if (json.containsKey("result")) {
|
||||||
basicModel.setResult(json.get("result"));
|
basicModel.setResult(json.get("result"));
|
||||||
}
|
}
|
||||||
mav.setModel(basicModel);
|
mav.setModel(basicModel);
|
||||||
@@ -2082,6 +2081,7 @@ public class AddressController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 地址信息分类接口
|
* 地址信息分类接口
|
||||||
|
*
|
||||||
* @param model
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -2095,7 +2095,7 @@ public class AddressController {
|
|||||||
|
|
||||||
HttpRequest request = new HttpRequest();
|
HttpRequest request = new HttpRequest();
|
||||||
JSONObject json = null;
|
JSONObject json = null;
|
||||||
try{
|
try {
|
||||||
Map<String, String> headers = new HashMap<String, String>();
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
headers.put("Content-Type", "application/json");
|
headers.put("Content-Type", "application/json");
|
||||||
|
|
||||||
@@ -2107,15 +2107,15 @@ public class AddressController {
|
|||||||
reqBody.put("housePurpose", model.getHousePurpose());
|
reqBody.put("housePurpose", model.getHousePurpose());
|
||||||
reqBody.put("memo", model.getMemo());
|
reqBody.put("memo", model.getMemo());
|
||||||
|
|
||||||
String result = request.postWithBody("http://192.168.0.100:32080/FangJiaAddressService/communitySummary", reqBody ,headers, "UTF-8");
|
String result = request.postWithBody("http://192.168.0.100:32080/FangJiaAddressService/communitySummary", reqBody, headers, "UTF-8");
|
||||||
if(result != null){
|
if (result != null) {
|
||||||
try{
|
try {
|
||||||
json = JSONObject.fromObject(result);
|
json = JSONObject.fromObject(result);
|
||||||
} catch(Exception e){
|
} catch (Exception e) {
|
||||||
json = null;
|
json = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2123,7 +2123,7 @@ public class AddressController {
|
|||||||
int code = json.getInt("status");
|
int code = json.getInt("status");
|
||||||
String msg = json.getString("msg");
|
String msg = json.getString("msg");
|
||||||
BasicModel basicModel = new BasicModel(code, msg);
|
BasicModel basicModel = new BasicModel(code, msg);
|
||||||
if(json.containsKey("result")){
|
if (json.containsKey("result")) {
|
||||||
basicModel.setResult(json.get("result"));
|
basicModel.setResult(json.get("result"));
|
||||||
}
|
}
|
||||||
mav.setModel(basicModel);
|
mav.setModel(basicModel);
|
||||||
@@ -2135,6 +2135,7 @@ public class AddressController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 楼盘评级
|
* 楼盘评级
|
||||||
|
*
|
||||||
* @param model
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -2148,7 +2149,7 @@ public class AddressController {
|
|||||||
|
|
||||||
HttpRequest request = new HttpRequest();
|
HttpRequest request = new HttpRequest();
|
||||||
JSONObject json = null;
|
JSONObject json = null;
|
||||||
try{
|
try {
|
||||||
Map<String, String> headers = new HashMap<String, String>();
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
headers.put("Content-Type", "application/json");
|
headers.put("Content-Type", "application/json");
|
||||||
|
|
||||||
@@ -2160,14 +2161,14 @@ public class AddressController {
|
|||||||
reqBody.put("housePurpose", model.getHousePurpose());
|
reqBody.put("housePurpose", model.getHousePurpose());
|
||||||
reqBody.put("memo", model.getMemo());
|
reqBody.put("memo", model.getMemo());
|
||||||
String result = request.postWithBody("http://192.168.0.100:32080/FangJiaAddressService/buildingRating", reqBody, headers, "UTF-8");
|
String result = request.postWithBody("http://192.168.0.100:32080/FangJiaAddressService/buildingRating", reqBody, headers, "UTF-8");
|
||||||
if(result != null){
|
if (result != null) {
|
||||||
try{
|
try {
|
||||||
json = JSONObject.fromObject(result);
|
json = JSONObject.fromObject(result);
|
||||||
} catch(Exception e){
|
} catch (Exception e) {
|
||||||
json = null;
|
json = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2175,7 +2176,7 @@ public class AddressController {
|
|||||||
int code = json.getInt("status");
|
int code = json.getInt("status");
|
||||||
String msg = json.getString("msg");
|
String msg = json.getString("msg");
|
||||||
BasicModel basicModel = new BasicModel(code, msg);
|
BasicModel basicModel = new BasicModel(code, msg);
|
||||||
if(json.containsKey("result")){
|
if (json.containsKey("result")) {
|
||||||
basicModel.setResult(json.get("result"));
|
basicModel.setResult(json.get("result"));
|
||||||
}
|
}
|
||||||
mav.setModel(basicModel);
|
mav.setModel(basicModel);
|
||||||
@@ -2187,20 +2188,21 @@ public class AddressController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 财力评级
|
* 财力评级
|
||||||
|
*
|
||||||
* @param model
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Object financialRatingAction(CommunitySummaryRequestDto model) {
|
public Object financialRatingAction(CommunitySummaryRequestDto model) {
|
||||||
|
|
||||||
RestfulModelAndView mav = new RestfulModelAndView();
|
RestfulModelAndView mav = new RestfulModelAndView();
|
||||||
if (StringUtils.isBlank(model.getAddress())) {
|
if (StringUtils.isBlank(model.getAddress()) || "null".equals(model.getAddress())) {
|
||||||
mav.setModel(BasicModel.buildBadRequestModel("地址不能为空"));
|
mav.setModel(BasicModel.buildBadRequestModel("地址不能为空"));
|
||||||
return mav;
|
return mav;
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest request = new HttpRequest();
|
HttpRequest request = new HttpRequest();
|
||||||
JSONObject json = null;
|
JSONObject json = null;
|
||||||
try{
|
try {
|
||||||
Map<String, String> headers = new HashMap<String, String>();
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
headers.put("Content-Type", "application/json");
|
headers.put("Content-Type", "application/json");
|
||||||
|
|
||||||
@@ -2211,15 +2213,15 @@ public class AddressController {
|
|||||||
reqBody.put("maxFloor", model.getMaxFloor());
|
reqBody.put("maxFloor", model.getMaxFloor());
|
||||||
reqBody.put("housePurpose", model.getHousePurpose());
|
reqBody.put("housePurpose", model.getHousePurpose());
|
||||||
reqBody.put("memo", model.getMemo());
|
reqBody.put("memo", model.getMemo());
|
||||||
String result = request.postWithBody("http://192.168.0.100:32080/FangJiaAddressService/financialRating", reqBody, headers,"UTF-8");
|
String result = request.postWithBody("http://192.168.0.100:32080/FangJiaAddressService/financialRating", reqBody, headers, "UTF-8");
|
||||||
if(result != null){
|
if (result != null) {
|
||||||
try{
|
try {
|
||||||
json = JSONObject.fromObject(result);
|
json = JSONObject.fromObject(result);
|
||||||
} catch(Exception e){
|
} catch (Exception e) {
|
||||||
json = null;
|
json = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2227,7 +2229,7 @@ public class AddressController {
|
|||||||
int code = json.getInt("status");
|
int code = json.getInt("status");
|
||||||
String msg = json.getString("msg");
|
String msg = json.getString("msg");
|
||||||
BasicModel basicModel = new BasicModel(code, msg);
|
BasicModel basicModel = new BasicModel(code, msg);
|
||||||
if(json.containsKey("result")){
|
if (json.containsKey("result")) {
|
||||||
basicModel.setResult(json.get("result"));
|
basicModel.setResult(json.get("result"));
|
||||||
}
|
}
|
||||||
mav.setModel(basicModel);
|
mav.setModel(basicModel);
|
||||||
@@ -2317,26 +2319,26 @@ public class AddressController {
|
|||||||
dto.append("township", address.getTownship());
|
dto.append("township", address.getTownship());
|
||||||
dto.append("street", address.getStreet());
|
dto.append("street", address.getStreet());
|
||||||
dto.append("streetNumber", address.getStreetNumber());
|
dto.append("streetNumber", address.getStreetNumber());
|
||||||
if(StringUtils.isBlank(building.getSuggestName())){
|
if (StringUtils.isBlank(building.getSuggestName())) {
|
||||||
if(StringUtils.isNotBlank(address.getParsedPropertyName())){
|
if (StringUtils.isNotBlank(address.getParsedPropertyName())) {
|
||||||
dto.append("name", address.getParsedPropertyName());
|
dto.append("name", address.getParsedPropertyName());
|
||||||
}else if(StringUtils.isNotBlank(address.getOrgKeywords())){
|
} else if (StringUtils.isNotBlank(address.getOrgKeywords())) {
|
||||||
dto.append("name", address.getOrgKeywords());
|
dto.append("name", address.getOrgKeywords());
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
dto.append("name", building.getSuggestName());
|
dto.append("name", building.getSuggestName());
|
||||||
}
|
}
|
||||||
if(StringUtils.isBlank(address.getStreet()) && StringUtils.isNotBlank(building.getAddress())){
|
if (StringUtils.isBlank(address.getStreet()) && StringUtils.isNotBlank(building.getAddress())) {
|
||||||
String addr = building.getAddress();
|
String addr = building.getAddress();
|
||||||
String street = AddressParserUtil.extractStreet(addr);
|
String street = AddressParserUtil.extractStreet(addr);
|
||||||
if(street != null){
|
if (street != null) {
|
||||||
dto.append("street", street);
|
dto.append("street", street);
|
||||||
if(addr.length() != street.length()){
|
if (addr.length() != street.length()) {
|
||||||
dto.append("streetNumber", AddressParserUtil.match(AddressParserUtil.STREET_NUMBER_CONNECTOR_PATTERN, addr));
|
dto.append("streetNumber", AddressParserUtil.match(AddressParserUtil.STREET_NUMBER_CONNECTOR_PATTERN, addr));
|
||||||
}
|
}
|
||||||
}else if(StringUtils.isNotBlank(building.getStreet())){
|
} else if (StringUtils.isNotBlank(building.getStreet())) {
|
||||||
dto.append("street", building.getStreet());
|
dto.append("street", building.getStreet());
|
||||||
if(StringUtils.isNotBlank(building.getStreetno())){
|
if (StringUtils.isNotBlank(building.getStreetno())) {
|
||||||
dto.append("streetNumber", building.getStreetno());
|
dto.append("streetNumber", building.getStreetno());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2346,7 +2348,7 @@ public class AddressController {
|
|||||||
dto.append("unitNumber", address.getUnitNumber());
|
dto.append("unitNumber", address.getUnitNumber());
|
||||||
dto.append("roomNumber", address.getRoomNumber());
|
dto.append("roomNumber", address.getRoomNumber());
|
||||||
dto.append("formattedAddress", address.getFormattedAddress());
|
dto.append("formattedAddress", address.getFormattedAddress());
|
||||||
if(matchParams.isContainsLocation()){
|
if (matchParams.isContainsLocation()) {
|
||||||
dto.append("lat", building.getLat());
|
dto.append("lat", building.getLat());
|
||||||
dto.append("lng", building.getLng());
|
dto.append("lng", building.getLng());
|
||||||
}
|
}
|
||||||
@@ -2772,7 +2774,7 @@ public class AddressController {
|
|||||||
check.setScore(score);
|
check.setScore(score);
|
||||||
check.setScoreIncity(null);
|
check.setScoreIncity(null);
|
||||||
check.setScoreInnation(null);
|
check.setScoreInnation(null);
|
||||||
}else if(GRADE_CONSUME.equals(type)) {
|
} else if (GRADE_CONSUME.equals(type)) {
|
||||||
check.setScoreIncity(null);
|
check.setScoreIncity(null);
|
||||||
check.setScoreInnation(null);
|
check.setScoreInnation(null);
|
||||||
check.setAreaScore(null);
|
check.setAreaScore(null);
|
||||||
@@ -3099,7 +3101,7 @@ public class AddressController {
|
|||||||
tr.setScore(score);
|
tr.setScore(score);
|
||||||
tr.setScoreIncity(null);
|
tr.setScoreIncity(null);
|
||||||
tr.setScoreInnation(null);
|
tr.setScoreInnation(null);
|
||||||
}else if(GRADE_CONSUME.equals(type)) {
|
} else if (GRADE_CONSUME.equals(type)) {
|
||||||
tr.setScoreIncity(null);
|
tr.setScoreIncity(null);
|
||||||
tr.setScoreInnation(null);
|
tr.setScoreInnation(null);
|
||||||
tr.setAreaScore(null);
|
tr.setAreaScore(null);
|
||||||
@@ -3173,6 +3175,7 @@ public class AddressController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 地址线下消费评级
|
* 地址线下消费评级
|
||||||
|
*
|
||||||
* @param model
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -3236,9 +3239,10 @@ public class AddressController {
|
|||||||
/**
|
/**
|
||||||
* 地址周边消费评级接口
|
* 地址周边消费评级接口
|
||||||
* <p>通过用户输入的地址,得到该地址的经纬度,找到该地址附近的三个非商住小区的小区消费评级评分,取一个平均分。<p>
|
* <p>通过用户输入的地址,得到该地址的经纬度,找到该地址附近的三个非商住小区的小区消费评级评分,取一个平均分。<p>
|
||||||
* @author yinjihuyan
|
*
|
||||||
* @param model
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
|
* @author yinjihuyan
|
||||||
*/
|
*/
|
||||||
public Object aroundConsumeGradeAction(AddressModel model) {
|
public Object aroundConsumeGradeAction(AddressModel model) {
|
||||||
RestfulModelAndView mav = new RestfulModelAndView();
|
RestfulModelAndView mav = new RestfulModelAndView();
|
||||||
@@ -3353,7 +3357,7 @@ public class AddressController {
|
|||||||
LOGGER.error("风险识别出错:" + ex.getMessage(), ex);
|
LOGGER.error("风险识别出错:" + ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
resultMap.put("riskLevel","C");
|
resultMap.put("riskLevel", "C");
|
||||||
resultModel.setResult(resultMap);
|
resultModel.setResult(resultMap);
|
||||||
mav.setModel(resultModel);
|
mav.setModel(resultModel);
|
||||||
return mav;
|
return mav;
|
||||||
@@ -3372,20 +3376,20 @@ public class AddressController {
|
|||||||
query.put("bool", bool);
|
query.put("bool", bool);
|
||||||
reqBody.put("query", query);
|
reqBody.put("query", query);
|
||||||
Base64 token = new Base64();
|
Base64 token = new Base64();
|
||||||
String authenticationEncoding = token.encodeAsString((""+ES_USER+":"+ES_PASSWORD+"").getBytes());
|
String authenticationEncoding = token.encodeAsString(("" + ES_USER + ":" + ES_PASSWORD + "").getBytes());
|
||||||
HttpRequest request = new HttpRequest();
|
HttpRequest request = new HttpRequest();
|
||||||
Map<String, String> headers = new HashMap<String, String>();
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
headers.put("Content-Type", "application/json");
|
headers.put("Content-Type", "application/json");
|
||||||
headers.put("Authorization", "Basic "+authenticationEncoding+"");
|
headers.put("Authorization", "Basic " + authenticationEncoding + "");
|
||||||
try {
|
try {
|
||||||
String response = request.postWithBody("http://192.168.0.45:9200/association/_search", reqBody, headers, "UTF-8");
|
String response = request.postWithBody("http://192.168.0.45:9200/association/_search", reqBody, headers, "UTF-8");
|
||||||
JSONObject json = JSONObject.fromObject(response);
|
JSONObject json = JSONObject.fromObject(response);
|
||||||
if(!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")){
|
if (!json.containsKey("hits") || !json.getJSONObject("hits").containsKey("hits")) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
JSONArray hits = json.getJSONObject("hits").getJSONArray("hits");
|
JSONArray hits = json.getJSONObject("hits").getJSONArray("hits");
|
||||||
List<JSONObject> results = new ArrayList<JSONObject>();
|
List<JSONObject> results = new ArrayList<JSONObject>();
|
||||||
for(int i=0 ;i < hits.size(); i++){
|
for (int i = 0; i < hits.size(); i++) {
|
||||||
JSONObject jsonObject = hits.getJSONObject(i);
|
JSONObject jsonObject = hits.getJSONObject(i);
|
||||||
results.add(jsonObject);
|
results.add(jsonObject);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user