+18
-18
@@ -12,10 +12,7 @@ import com.fangjia.open.model.RestfulModelAndView;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 商业地产
|
||||
@@ -36,12 +33,17 @@ public class CommercialController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
JSONObject json = locationEvaluateApi(model.getAddress(), model.getLocation(), String.valueOf(model.getSize()), String.valueOf(model.getEstateType()));
|
||||
JSONObject json = locationEvaluateApi(model);
|
||||
if (json != null) {
|
||||
if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
|
||||
HashMap<String, Long> resultMap = new HashMap<String, Long>();
|
||||
HashMap<String, Object> resultMap = new HashMap<String, Object>();
|
||||
resultMap.put("avgPrice", Long.valueOf(json.getString("unitPrice")));
|
||||
resultMap.put("totalPrice", Long.valueOf(json.getString("totalPrice")));
|
||||
|
||||
if (model.getShowSample()!=null && model.getShowSample()==1 && json.containsKey("case")) {
|
||||
resultMap.put("samples", json.get("case"));
|
||||
}
|
||||
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(resultMap));
|
||||
} else {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("该地址不支持估价!"));
|
||||
@@ -61,15 +63,13 @@ public class CommercialController {
|
||||
if(mav.model()!=null){
|
||||
return mav;
|
||||
}
|
||||
JSONObject json = locationEvaluateApi(model.getAddress(), model.getLocation(), String.valueOf(model.getSize()), String.valueOf(model.getEstateType()));
|
||||
JSONObject json = locationEvaluateApi(model);
|
||||
if (json != null) {
|
||||
if (json.containsKey("msg") && "成功".equals(json.getString("msg"))) {
|
||||
String msg = json.getString("msg");
|
||||
BasicModel basicModel = new BasicModel(200, "ok");
|
||||
List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
|
||||
if (json.containsKey("case")) {
|
||||
basicModel.setResult(json.get("case"));
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(json.get("case")));
|
||||
}
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(basicModel));
|
||||
}
|
||||
} else {
|
||||
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
|
||||
@@ -125,20 +125,20 @@ public class CommercialController {
|
||||
}
|
||||
|
||||
|
||||
private JSONObject locationEvaluateApi(String address, String location, String area, String estateType){
|
||||
private JSONObject locationEvaluateApi(CommercialModel model){
|
||||
//商铺类型---0:临街商铺 1:住宅底商 2:购物百货中心 3:写字楼商铺 4:档口摊位 5:市场类商铺 6:交通设施商铺 7:旅游商铺
|
||||
HttpRequest request = new HttpRequest();
|
||||
JSONObject json = null;
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
if(StringUtils.isNotBlank(address)){
|
||||
params.put("address", address);
|
||||
if(StringUtils.isNotBlank(model.getAddress())){
|
||||
params.put("address", model.getAddress());
|
||||
}
|
||||
if(StringUtils.isNotBlank(location)){
|
||||
params.put("location", location);
|
||||
if(StringUtils.isNotBlank(model.getLocation())){
|
||||
params.put("location", model.getLocation());
|
||||
}
|
||||
|
||||
params.put("area", area);
|
||||
params.put("estateType", estateType);
|
||||
params.put("area", String.valueOf(model.getSize()));
|
||||
params.put("estateType", String.valueOf(model.getEstateType()));
|
||||
try {
|
||||
json = request.getJsonContent("http://192.168.0.100:30020/avmWeb/shopSell", params, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -21,6 +21,8 @@ public class CommercialModel extends FangjiaApiModel{
|
||||
@NotBlank
|
||||
private Integer estateType;//商铺类型---0:临街商铺 1:住宅底商 2:购物百货中心 3:写字楼商铺 4:档口摊位 5:市场类商铺 6:交通设施商铺 7:旅游商铺
|
||||
|
||||
private Integer showSample;//是否显示样本 1:显示
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
@@ -108,4 +110,12 @@ public class CommercialModel extends FangjiaApiModel{
|
||||
public void setEstateType(Integer estateType) {
|
||||
this.estateType = estateType;
|
||||
}
|
||||
|
||||
public Integer getShowSample() {
|
||||
return showSample;
|
||||
}
|
||||
|
||||
public void setShowSample(Integer showSample) {
|
||||
this.showSample = showSample;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user