open新增涉农新规接口

This commit is contained in:
mjt
2024-02-26 13:46:04 +08:00
parent 2932c736cf
commit fd9c30d68c
2 changed files with 76 additions and 7 deletions
@@ -206,7 +206,7 @@ public class AddrSvcController {
//新匹配接口
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8");
BasicModel basicModel = new BasicModel(200, "ok");
if (json != null && json.size()>0) {
if (json != null && json.size() > 0) {
basicModel.setResult(CommonDtoUtils.transformV(MatchedBuildingDto.class, json));
}
mav.setModel(basicModel);
@@ -284,16 +284,16 @@ public class AddrSvcController {
//新匹配接口
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8");
BasicModel basicModel = new BasicModel(200, "ok");
if (json != null && json.size()>0) {
if (json != null && json.size() > 0) {
MatchedBuildingDto dto = CommonDtoUtils.transformV(MatchedBuildingDto.class, json);
District district = districtService.findByNameAndAlias(dto.getCity(), dto.getDistrict(), dto.getName(),"district");
District district = districtService.findByNameAndAlias(dto.getCity(), dto.getDistrict(), dto.getName(), "district");
if (null != district) {
DistrictStatBo statBo = districtStatService.findCurrentDistrictStat(new DistrictKey(dto.getCity(), dto.getDistrict(), dto.getName()));
if(null != statBo){
if(statBo.getDistrictStat()!=null){
if (null != statBo) {
if (statBo.getDistrictStat() != null) {
dto.setAvgPrice(statBo.getDistrictStat().getAvgPrice());
}else if(statBo.getVillaDistrictStat()!=null){
} else if (statBo.getVillaDistrictStat() != null) {
dto.setAvgPrice(statBo.getVillaDistrictStat().getAvgPrice());
}
@@ -309,8 +309,9 @@ public class AddrSvcController {
return mav;
}
/**
*五级地址标准化
* 五级地址标准化
*
* @param model
* @return
@@ -357,6 +358,54 @@ public class AddrSvcController {
return mav;
}
/**
* 涉农识别-新规则
*
* @param model
* @return
*/
public Object villageIdentifyAction(AddressModel 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() : null);
params.put("address", model.getAddress());
params.put("type", StringUtils.isNotBlank(model.getType()) ? model.getType() : null);
params.put("showFullValue", StringUtils.isNotBlank(model.getShowFullValue()) ? model.getShowFullValue() : null);
params.put("showTestValue", StringUtils.isNotBlank(model.getShowTestValue()) ? model.getShowTestValue() : null);
Integer radius = model.getRadius();
params.put("radius", (radius != null && radius != 0) ? radius.toString() : null);
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8");
} catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/villageIdentify", params, "UTF-8");
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (json != null) {
int code = json.getInt("msgCode");
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 void setDistrictStatService(DistrictStatService districtStatService) {
this.districtStatService = districtStatService;
}
@@ -42,6 +42,10 @@ public class AddressModel extends FangjiaApiModel {
//是否使用地图poi数据
private boolean useMap;
//涉农到区之后,是否显式后面的字段值
private String showFullValue;
//是否显示涉农测试用字段值
private String showTestValue;
public boolean isContainsLocation() {
return containsLocation;
}
@@ -258,4 +262,20 @@ public class AddressModel extends FangjiaApiModel {
public void setUseMap(boolean useMap) {
this.useMap = useMap;
}
public String getShowFullValue() {
return showFullValue;
}
public void setShowFullValue(String showFullValue) {
this.showFullValue = showFullValue;
}
public String getShowTestValue() {
return showTestValue;
}
public void setShowTestValue(String showTestValue) {
this.showTestValue = showTestValue;
}
}