Merge branch 'open_gj' into 'master'

新增地址标准化测试专用接口

See merge request !273
This commit is contained in:
2022-03-10 09:42:55 +08:00
@@ -1814,7 +1814,7 @@ public class AddressController {
HttpRequest request = new HttpRequest();
JSONObject json = null;
Map<String, String> params = new HashMap<String, String>();
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : "重庆市");
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : CONFIG.getDefaultCity());
params.put("address", model.getAddress());
// 地址验证无效也输出标准化结果
params.put("flag", "true");
@@ -1842,6 +1842,50 @@ public class AddressController {
return mav;
}
/**
* 地址标准化专用测试接口
* @param model
* @return
*/
public Object structureForTestAction(AddesssMatchModel model) {
RestfulModelAndView mav = new RestfulModelAndView();
if (StringUtils.isBlank(model.getAddress())) {
mav.setModel(BasicModel.buildBadRequestModel("地址不能为空"));
return mav;
}
HttpRequest request = new HttpRequest();
JSONObject json = null;
Map<String, String> params = new HashMap<String, String>();
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : CONFIG.getDefaultCity());
params.put("address", model.getAddress());
// 地址验证无效也输出标准化结果
params.put("flag", "true");
try{
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structureForTest", params, "UTF-8");
} catch(Exception e){
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/structureForTest", params, "UTF-8");
} catch(Exception ex){
ex.printStackTrace();
}
}
if (json != null) {
int code = json.getInt("status");
String msg = json.getString("msg");
BasicModel basicModel = new BasicModel(code, msg);
if(json.containsKey("result")){
basicModel.setResult(json.get("result"));
}
mav.setModel(basicModel);
} else {
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
}
return mav;
}
public Object similarityAction(AddesssMatchModel model) {
RestfulModelAndView mav = new RestfulModelAndView();
if (StringUtils.isBlank(model.getAddress_1()) || StringUtils.isBlank(model.getAddress_2())) {