Merge branch 'open_v2' into 'master'
新增地址匹配和均价合并接口 See merge request !743
This commit is contained in:
+61
@@ -1,6 +1,8 @@
|
|||||||
package com.fangjia.open.controllers;
|
package com.fangjia.open.controllers;
|
||||||
|
|
||||||
import com.fangjia.core.util.HttpRequest;
|
import com.fangjia.core.util.HttpRequest;
|
||||||
|
import com.fangjia.dal.common.DistrictKey;
|
||||||
|
import com.fangjia.dal.seaweed.model.District;
|
||||||
import com.fangjia.open.dto.addressGovernance.*;
|
import com.fangjia.open.dto.addressGovernance.*;
|
||||||
import com.fangjia.open.interceptors.Authority;
|
import com.fangjia.open.interceptors.Authority;
|
||||||
import com.fangjia.open.interceptors.Role;
|
import com.fangjia.open.interceptors.Role;
|
||||||
@@ -9,6 +11,9 @@ import com.fangjia.open.model.AddressModel;
|
|||||||
import com.fangjia.open.model.BasicModel;
|
import com.fangjia.open.model.BasicModel;
|
||||||
import com.fangjia.open.model.RestfulModelAndView;
|
import com.fangjia.open.model.RestfulModelAndView;
|
||||||
import com.fangjia.open.util.CommonDtoUtils;
|
import com.fangjia.open.util.CommonDtoUtils;
|
||||||
|
import com.fangjia.service.bo.DistrictStatBo;
|
||||||
|
import com.fangjia.service.datastore.DistrictService;
|
||||||
|
import com.fangjia.service.district.DistrictStatService;
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
@@ -24,6 +29,9 @@ import java.util.Map;
|
|||||||
@Authority(role = Role.USER)
|
@Authority(role = Role.USER)
|
||||||
public class AddrSvcController {
|
public class AddrSvcController {
|
||||||
|
|
||||||
|
private DistrictStatService districtStatService;
|
||||||
|
private DistrictService districtService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地址结构化
|
* 地址结构化
|
||||||
*
|
*
|
||||||
@@ -256,4 +264,57 @@ public class AddrSvcController {
|
|||||||
}
|
}
|
||||||
return mav;
|
return mav;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object avgPriceAction(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", model.getCity());
|
||||||
|
params.put("address", model.getAddress());
|
||||||
|
params.put("category", model.getCategory());
|
||||||
|
params.put("useMap", String.valueOf(model.isUseMap()));
|
||||||
|
// params.put("district", model.getSuggestDistrict());//接口没有此参数
|
||||||
|
try {
|
||||||
|
//新匹配接口
|
||||||
|
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) {
|
||||||
|
MatchedBuildingDto dto = CommonDtoUtils.transformV(MatchedBuildingDto.class, json);
|
||||||
|
|
||||||
|
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){
|
||||||
|
dto.setAvgPrice(statBo.getDistrictStat().getAvgPrice());
|
||||||
|
}else if(statBo.getVillaDistrictStat()!=null){
|
||||||
|
dto.setAvgPrice(statBo.getVillaDistrictStat().getAvgPrice());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
basicModel.setResult(dto);
|
||||||
|
}
|
||||||
|
mav.setModel(basicModel);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
|
||||||
|
}
|
||||||
|
|
||||||
|
return mav;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistrictStatService(DistrictStatService districtStatService) {
|
||||||
|
this.districtStatService = districtStatService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistrictService(DistrictService districtService) {
|
||||||
|
this.districtService = districtService;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
@@ -46,6 +46,11 @@ public class MatchedBuildingDto {
|
|||||||
*/
|
*/
|
||||||
private String propertyType;
|
private String propertyType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 均价
|
||||||
|
*/
|
||||||
|
private Integer avgPrice;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -125,4 +130,12 @@ public class MatchedBuildingDto {
|
|||||||
public void setPropertyType(String propertyType) {
|
public void setPropertyType(String propertyType) {
|
||||||
this.propertyType = propertyType;
|
this.propertyType = propertyType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getAvgPrice() {
|
||||||
|
return avgPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvgPrice(Integer avgPrice) {
|
||||||
|
this.avgPrice = avgPrice;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ public class AddressModel extends FangjiaApiModel {
|
|||||||
private String dataLevel;
|
private String dataLevel;
|
||||||
|
|
||||||
private String keyword;
|
private String keyword;
|
||||||
|
//是否使用地图poi数据
|
||||||
|
private boolean useMap;
|
||||||
|
|
||||||
public boolean isContainsLocation() {
|
public boolean isContainsLocation() {
|
||||||
return containsLocation;
|
return containsLocation;
|
||||||
@@ -248,4 +250,12 @@ public class AddressModel extends FangjiaApiModel {
|
|||||||
public void setRegion(String region) {
|
public void setRegion(String region) {
|
||||||
this.region = region;
|
this.region = region;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isUseMap() {
|
||||||
|
return useMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUseMap(boolean useMap) {
|
||||||
|
this.useMap = useMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user